﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using CarwashLibrary;
using CarwashLibrary.CW_Storage;
using CarwashLibrary.CW_Security;
using CarwashLibrary.CW_Management;
using CarwashLibrary.CW_Functions;

namespace Carwash
{
    class CW_EventHandler
    {
        private CW_Storage_Facade storage_facade = new CW_Storage_Facade();
        private CW_Security_Facade security_facade = new CW_Security_Facade();
        private CW_Management_Facade management_facade = new CW_Management_Facade();
        private LogPrinter log_printer = new LogPrinter();
        private CW_Functions_Facade functions_facade = new CW_Functions_Facade();
        private static CW_Security_Facade _securityInstance = null;

        /// <summary>
        /// this method will drive the execution of the user requests   
        /// </summary>
        /// <param name="eventType"></param>
        /// <returns>returns whether the event was completed succesfully</returns>
        public bool processEvent(int eventType)
        {
            return false;
        }

        //Storage_Facade
        public string getPassword(int PIN)
        {
            return storage_facade.getPassword(PIN);
        }

        public string[] getPINData(int PIN)
        {
            return storage_facade.getPINData(PIN);
        }

        public bool addRecord(int PIN, int pinType)
        {
            return storage_facade.addRecord(PIN, pinType, null);
        }

        public bool addRecord(int PIN, int pinType, string password)
        {
            return storage_facade.addRecord(PIN, pinType, password);
        }

        public bool addSLogEntry(string newLog)
        {
            return storage_facade.addLogEntry(newLog);
        }

        public ArrayList retrieveLogs()
        {
            return storage_facade.retrieveLogs();
        }
        
        //Management_Facade
        public string displayLogs()
        {
            return log_printer.displayLogs();
        }

        public bool addMLogEntry(string newLog)
        {
            return log_printer.addLogEntry(newLog);
        }

        public bool enterPassword(string password)
        {
            return management_facade.enterPassword(password);
        }

        public bool logOut()
        {
            return management_facade.logOut();
        }

        public bool systemShutDown()
        {
            return management_facade.systemShutDown();
        }

        public int requestFreeCarwash()
        {
            return management_facade.requestFreeCarwash();
        }

        public bool systemTurnOn()
        {
            return management_facade.systemTurnOn();
        }

        public void clearLogs()
        {
            log_printer.clearLogs();
        }

        //Functions Facade
        public int enterPin(int pin)
        {
            return functions_facade.enterPin(pin);
        }

        public int requestCarwash(int cwRequested)
        {
            return functions_facade.requestCarwash(cwRequested);
        }

        public bool payCarwashWithCash()
        {
            return functions_facade.payCarwashWithCash();
        }

        public bool payCarwashWithCreditCard(string cardNumber)
        {
            return payCarwashWithCreditCard(cardNumber);
        }

        public bool validatePassword(int pin, int password)
        {
            return security_facade.validatePassword(pin, password);
        }

        public bool maxNumPasswordAttemptsExceeded()
        {
            return (security_facade.maxNumPasswordAttemptsExceeded());
        }

        public void resetPasswordAttempts()
        {
            security_facade.resetPasswordAttempts();
        }

        public int validatePin(int pin)
        {
            return security_facade.validatePin(pin);
        }

        public bool maxNumPinAttemptsExceeded()
        {
            return (security_facade.maxNumPinAttemptsExceeded());
        }

        public void resetPinAttempts()
        {
            security_facade.resetPinAttempts();
        }

        public bool verifyPasswordLength(string password)
        {
            return security_facade.verifyPasswordLength(password);
        }
    }
}
